import {request} from '../../request/index.js'
import regeneratorRuntime, { async } from '../../lib/runtime/runtime';
page({
  onLoad: function (options) {
    this.checkToken();
  },
  async checkToken(){
    var token = wx.getStorageSync('token')
    if (token){
      const res = await request({
        url: '/user/verify',
        header:{
          'Authorization':'Bearer '+ token,
        },
        method: "get",
      })
      if (res.data.status !== 200){
        var title = res.data.msg
        wx.showToast({
          title: title,
          icon: 'none',
          duration: 2000
        })
        wx.reLaunch ({
          url: '/pages/index/index'
        });
      } 
      // else {
      //   wx.navigateTo({
      //     url: '/pages/my/my'
      //   });
      // }
    }
  }
})